#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "../../include/sort.h"


static void print_idata(int *s, int size)
{
	int i;
	for (i = 0; i < size; i++)
		fprintf(stdout, "s[%d] = %d\n", i, s[i]);

	return;
}

static int compare_int(const void *key1, const void *key2)
{
	if (*(int *)key1 > *(int *)key2)
		return 1;
	if (*(int *)key1 < *(int *)key2)
		return -1;
	else
		return 0;
}


int main(int argc, char *argv[])
{
	int qarray[10];
	int iarray[10] = {0, 5, 1, 7, 3, 2, 8, 9, 4, 6};

	int size = 10;
	memcpy(qarray, iarray, sizeof(int) * size);

	fprintf(stdout, "original array is \n");
	print_idata(iarray, size);

	#if 0
	if (issort((void *)iarray, size, sizeof(int), compare_int))
		return 1;
	fprintf(stdout, "after insert_sort is \n");
	print_idata(iarray, size);
	#endif


	qksort(iarray, size, sizeof(int), 0, size - 1, compare_int);
	fprintf(stdout, "after qk_sort is \n");
	print_idata(iarray, size);


	return 0;
}
